program main
    implicit none
    integer :: i,j,k
    integer,parameter :: head=100,tail=200
    integer,allocatable :: prime(:)
    integer :: init(2:tail)
    logical,external :: judge

    !生成tail以内的质数表
    init = (/ (i,i=2,tail) /)! init(i) = i
    do i=2,tail
        if( .not.(judge(init(i))) ) init(i)=0! 不是质数的全赋值为0
    end do
    i = count(init>0)
    allocate(prime(i))
    prime=pack(init,init>0)! 保留大于0的数据

    do j=head,tail,2
        k=1
        do while( .not.(count(prime==j-prime(k))>0) )
            k = k+1
        end do
        write(*,1) j,'=',prime(k),'+',j-prime(k)
    end do
1   format(i3,a1,i3,a1,i3)
end program

logical function judge(n)
    !判断整数n是否是质数.是返回.true.
    integer :: n,i
    real :: r
    judge=.true.
    i=2
    if (n==2) then!特殊情况 
        goto 2
    end if
    r = sqrt(real(n))
    do while(i<=int(r))!寻找是否含有因数
        if(mod(n,i)==0) then
            judge = .false.
            goto 2
        end if
        i=i+1
    end do
2   continue
end function
